<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>订单管理系统</title>
  <link href="/css/bootstrap.css" rel="stylesheet">
  <script src="/js/bootstrap.bundle.js"></script>
  <style>
      body {
          padding-top: 56px;
      }
      .sidebar {
          height: 100%;
          width: 250px;
          position: fixed;
          top: 56px;
          left: 0;
          background-color: #f8f9fa;
          padding-top: 20px;
      }
      .sidebar a {
          padding: 10px 15px;
          text-align: left;
          display: block;
          color: #000;
          text-decoration: none;
      }
      .sidebar a:hover {
          background-color: #ddd;
          color: black;
      }
      .content {
          margin-left: 250px;
          padding: 20px;
      }
  </style>
</head>

<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
  <a class="navbar-brand" href="#">订单管理系统</a>
  <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav"
          aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav ml-auto">
      <li class="nav-item">
        <a class="nav-link" href="#">欢迎您，管理员（ID: <span th:text="${session.name}"></span>）</a>
      </li>
      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="settingsDropdown" role="button" data-bs-toggle="dropdown"
           aria-haspopup="true" aria-expanded="false">
          设置
        </a>
        <div class="dropdown-menu dropdown-menu-right" aria-labelledby="settingsDropdown">
          <div th:if="${session.isTotalAdmin}">
            <a class="dropdown-item" th:href="@{/inventory}">进入仓库管理</a>
            <a class="dropdown-item" th:href="@{/user/sysAdmin}">进入系统管理</a>
            <div class="dropdown-divider"></div>
          </div>
          <a class="dropdown-item" th:href="@{/logout}">退出登录</a>
          <a class="dropdown-item" href="#" onclick="location.reload();">刷新页面</a>
        </div>
      </li>
    </ul>
  </div>
</nav>

<!-- Sidebar -->
<div class="sidebar">
  <a th:href="@{/order}">全部订单信息</a>
  <a th:href="@{/order/query}">订单查询</a>
  <a th:href="@{/order/manage}">订单管理</a>
  <a th:href="@{/order/reminder}">临近截至订单提醒</a>
  <a th:href="@{/order/demand}">需求原料</a>
  <a th:href="@{/order/supplier}">供应商管理</a>
</div>
<div class="content">
  <div id="orderQuerySection" class="section" >
    <h3>订单查询</h3>
    <!--  查询表单  -->
    <form action="/order/query" method="post">
      <div class="row">
        <div class="form-group col">
          <label for="start">起始时间</label>
          <input type="date" class="form-control" id="start" name="start" placeholder="yyyy-mm-dd">
        </div>
        <div class="form-group col">
          <label for="end">截止时间</label>
          <input type="date" class="form-control" id="end" name="end" placeholder="yyyy-mm-dd">
        </div>
      </div>
      <div class="form-group">
        <label for="queryMaterialName">按原料名查询</label>
        <input type="text" class="form-control" id="queryMaterialName" name="materialName">
      </div>
      <div class="form-group">
        <label for="queryInventory">按仓库查询</label>
        <select class="form-control" id="queryInventory" name="inventory">
          <option value="">选择仓库</option>
          <option th:each="inventory : ${session.inventories}" th:value="${inventory.getInventoryName}" th:text="${inventory.getInventoryName}"></option>
        </select>
      </div>
      <div class="form-group">
        <label for="queryOrderStatus">按订单状态查询</label>
        <select class="form-control" id="queryOrderStatus" name="status">
          <option value="">选择状态</option>
          <option value="进行中">进行中</option>
          <option value="已完成">已完成</option>
        </select>
      </div>
      <button type="submit" class="btn btn-primary">查询</button>
    </form>
    <table class="table mt-4">
      <thead>
      <tr>
        <th>ID</th>
        <th>原料名</th>
        <th>数量</th>
        <th>价格</th>
        <th>仓库名</th>
        <th>订单状态</th>
        <th>完成日期</th>
        <th>供应商</th>
      </tr>
      </thead>
      <tbody>
      <!-- 查询结果数据 -->
      <tr th:each="order : ${ordersQuery}">
        <td th:text="${order.getOrderId()}"></td>
        <td th:text="${order.getMaterialName()}"></td>
        <td th:text="${order.getMaterialNumber()}"></td>
        <td th:text="${order.getPrice()}"></td>
        <td th:text="${order.getInventoryName()}"></td>
        <td th:text="${order.getStatus()}"></td>
        <td th:text="${order.getEndTime()}"></td>
        <td th:text="${order.getSupplierName()}"></td>
      </tr>
      </tbody>
    </table>
  </div>
</div>


</body>
</html>